#include "VisableObject.h"
#include "texturelibrary.h"
#include <iostream>

void VisableObject::MakeSprite(float scale, sf::Vector2f startPos)
{
	sf::Texture *myTexture = NULL;
	myTexture = TT::TextureLibrary[imageFilename];
	// Make a sprite and set its origin:
	if (myTexture != NULL)
	{
		mySprite = sf::Sprite(*myTexture);
		mySprite.setOrigin(myTexture->getSize().x * 0.5f, myTexture->getSize().y * 0.5f);
		mySprite.setScale(sf::Vector2f(scale, abs(scale)));
		radius = mySprite.getTexture()->getSize().x * 0.5f * abs(scale);
	}
	else
	{
		cout << "ERROR: Objects texture does not exist!!" << endl;
	}

	// Position the sprite:
	mySprite.setPosition(startPos);
}

void VisableObject::Render(sf::RenderWindow* window)
{
	mySprite.setPosition(pos);
	window->draw(mySprite);
}